import { handleMessageInit, editPassword, handleUpdatePassword, handleEditPhone, handleGetPhone, handleEditPhoneUpdate } from '@/api/home';

const home = {
  actions: {
    handleGetMessage({ commit }) {
      return new Promise((resolve, reject) => {
        handleMessageInit().then(response => {
          commit('setMessageCount', response.data.data.count); // 显示消息条数
        })
      })
    },
    handleGetPhoneInit({}) {
      return new Promise((resolve, reject) => {
        handleGetPhone().then(response => {
          resolve(response.data.data.phone)
        })
      })
    },
    hacdlePassWordEdit({}, oldPwd) {
      return new Promise((resolve, reject) => {
        editPassword(oldPwd).then(response => {
          resolve(response)
        })
      })
    },
    handleUpdateEditPassword({}, newPwd) {
      return new Promise((resolve, reject) => {
        handleUpdatePassword(newPwd).then(response => {
          resolve(response)
        })
      })
    },
    handleGetPhoneCode({}) {
      return new Promise((resolve, reject) => {
        handleEditPhone().then(response => {
          resolve(response)
        })
      })
    },
    handlePostEditPhone({}, date) {
      return new Promise((resolve, reject) => {
        handleEditPhoneUpdate(date).then(response => {
          resolve(response)
        })
      })
    }
  }
}

export default home;